package com.sikao.app.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.sikao.app.R;

/**
 * Created by y50 on 2016/4/27.
 */
public class BusinessAdapter extends BaseAdapter {

	private Context context;

	public BusinessAdapter(Context context){
		this.context = context;
	}
	@Override
	public int getCount() {
		return 5;
	}

	@Override
	public Object getItem(int position) {
		return null;
	}

	@Override
	public long getItemId(int position) {
		return 0;
	}


	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		View view;
		ViewHolder holder;
		if (convertView == null){
			view = View.inflate(context, R.layout.business_list_item,null);
			holder = new ViewHolder(view);
			view.setTag(holder);
		}else{
			view = convertView;
			holder = (ViewHolder) view.getTag();
		}
		if (position == 0){
			holder.viewLine.setVisibility(View.GONE);
		}else {
			holder.viewLine.setVisibility(View.VISIBLE);
		}
		holder.nameTv.setText("动力煤");
		holder.deliveryModeTv.setText("买家自提");
		holder.priceTv.setText("1200");
		holder.releaseTypeTv.setText("信誉挂单");
		holder.deliveryPlaceTv.setText("青岛");
		holder.quantityTv.setText("1200");
		return view;
	}

	public class ViewHolder {
		private TextView nameTv;
		private TextView releaseTypeTv;
		private TextView canSplitTv;
		private TextView priceTv;
		private TextView priceUnitTv;
		private TextView quantityTv;
		private TextView deliveryPlaceTv;
		private TextView deliveryModeTv;
		public final View root;
		public final View viewLine;

		public ViewHolder(View root) {
			nameTv = (TextView) root.findViewById(R.id.name_tv);
			releaseTypeTv = (TextView) root.findViewById(R.id.release_type_tv);
			canSplitTv = (TextView) root.findViewById(R.id.can_split_tv);
			priceTv = (TextView) root.findViewById(R.id.price_tv);
			priceUnitTv = (TextView) root.findViewById(R.id.price_unit_tv);
			quantityTv = (TextView) root.findViewById(R.id.quantity_tv);
			deliveryPlaceTv = (TextView) root.findViewById(R.id.delivery_place_tv);
			deliveryModeTv = (TextView) root.findViewById(R.id.delivery_mode_tv);
			viewLine = root.findViewById(R.id.view_line);
			this.root = root;
		}
	}
}
